// pages/check/card/add/add.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
XingszPic:'',
DianChiNumber:'',
CarPic:'',
http:getApp().globalData.map
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		wx.getStorage({
			key: 'uid',
			success: (e) => {
				this.setData({
					uid: e.data.uid
				})
			}
		})
	},
	name(e) {
		this.setData({
			Pname: e.detail.value
		})
	},
	mobile(e) {
		this.setData({
			mobile: e.detail.value
		})
	},
	card(e) {
		this.setData({
			CarNumber: e.detail.value
		})
	},
	dc(e) {
		this.setData({
			DianChiType: e.detail.value
		})
	},
	time1(e) {
		this.setData({
			BaoZhiQi: e.detail.value
		})
	},
	time(e) {
		this.setData({
			AddTime: e.detail.value
		})
	},
	sure() {
		wx.request({
			url:getApp().globalData.chang+'action=addOfflineSale&uid='+this.data.uid+'&Pname='+this.data.Pname+'&mobile='
			+this.data.mobile+'&CarNumber='+this.data.CarNumber+'&DianChiType='+this.data.DianChiType+'&BaoZhiQi='+this.data.BaoZhiQi
			+'&AddTime='+this.data.AddTime+'&DianChiNumber='+this.data.DianChiNumber+'&CarPic='+this.data.CarPic+'&XingszPic='
			+this.data.XingszPic,
			success:(e)=>{ 
				console.log(e)
				wx.navigateBack({
					delta:1
				})
			}
		})
	},
	img(eve) {
		let that=this
		wx.chooseImage({
			count: 1,
			sizeType: 'compressed',
			success: (e) => {
				console.log(e)
				wx.uploadFile({
					url: getApp().globalData.http3,
					filePath: e.tempFilePaths[0],
					name: 'picturePath',
					success: function(res) {
						let c = JSON.parse(res.data)
						console.log(c.data.headImage)
						if (eve.currentTarget.dataset.id == 1) {
							that.setData({
								XingszPic: c.data.headImage
							})
						} else if (eve.currentTarget.dataset.id == 2) {
							that.setData({
								DianChiNumber: c.data.headImage
							})
						} else {
							that.setData({
								CarPic: c.data.headImage
							})
						}
					},
				})

			}
		})
	}
})
